<!DOCTYPE html>
<?php
 require 'common/mysqlCommon.php';  //将其他的php文件的代码引入当前页面
?>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    <link rel="stylesheet" href="zhuce.css">
    <style>
        h1{
            text-align: center;
            position:relative;
            top:100px;
        }
    </style>
    </head>
    <body>
        <?php 
        $frist=!count($_POST);
        if($frist){
           //第一次访问 页面进行渲染
        ?>
           <h1>注册</h1>
           <div id="bigBox">
           <div class="inputBox">
           <div class="inputText">
        <form action="zhuce.php" method="post">
            <div class="inputText">
            <input type="text" id="USERname" name="username" placeholder="用户名"><br/>
            </div>
            <div class="inputText">
            <input type="password" id="pwd" name="upwd" placeholder="密码" ><br/>
            </div>
            <div class="inputText">
            <input type="text" id="QQ" name="QQ" placeholder="QQ" ><br/>
            </div>
            <div class="inputText">
            <input type="email" id="email" name="email" placeholder="邮箱" ><br/>
            </div>
            <div class="inputText">
           <input type="text" id="phone" name="phone" placeholder="手机号" ><br/>
            </div>
            <div class="inputText1"><input type="text" id="mycode" name="mycode" placeholder="验证码"><img src="codes.php"/><br/></div>
            <br/>
            <div class="xhz">    
                <div class="qd"><input type="submit" style="background-color: gray" value="确定"/></div>
                <div class="qx"><input type="reset" style="background-color: gray" value="取消"/></div>
            </div>
        </form>
           </div>
           </div>
           </div>
        <?php
        }else{
           
            $name=$_POST["username"];
            $pwd=$_POST["upwd"];
            $QQ=$_POST["QQ"];
            $email=$_POST["email"];
            $phone=$_POST["phone"];
            $sqlstring="INSERT INTO `yonghu`(`username`, `upwd`, `QQ`,`email`,`phone`)"
                        . " VALUES ('${name}','${pwd}',${QQ},'${email}','${phone}')";
            $result= getResultBySQL($sqlstring);
            if($result){
                echo "<script>alert('添加成功!!');"
                    . "location='weblogin.php';</script>";
            }else{
                echo "<script>alert('添加失败,请重试!!');"
                    . "location='zhuce.php';</script>";
            }
        }
        ?>
     
        <?php
        
        ?>
    </body>
</html>
